-module(test).
-include("ejabberd_commands.hrl").
-export([calc_power/2, register/0, exe/1]).

calc_power(Base, Exponent) ->
    PowFloat = math:pow(Base, Exponent),
    round(PowFloat).

commands() ->
    [#ejabberd_commands{name = pow, tags = [test],
                        desc = "this is desc",
                        longdesc = "this is longdesc", module = ?MODULE, function = calc_power,
                        args = [{base, integer}, {exponent, integer}],
                        result = {power, integer}}].

%% 该模块依赖于logger模块.
register() ->
    ejabberd_loglevel:set(5),
    ejabberd_commands:init(),
    ejabberd_commands:register_commands(commands()).

%% E.g. exe([1, 2])
exe(Args) ->
    ejabberd_commands:execute_command(pow, Args).
